package cz.cvut.fit.mi_paa.sat;

import cz.cvut.fit.mi_paa.abs.Instance;

import java.util.List;

/**
 * Created with IntelliJ IDEA.
 * User: milos
 * Date: 27.1.13
 * Time: 22:03
 * To change this template use File | Settings | File Templates.
 */
public class SatInstance extends Instance {
    private String id;
    private int variableNum;
    private int[] weights;
    private int bestWeight;
    private List<Term> terms;

    public SatInstance() {
    }

    public int getVariableNum() {
        return variableNum;
    }

    public void setVariableNum(int variableNum) {
        this.variableNum = variableNum;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public int[] getWeights() {
        return weights;
    }

    public void setWeights(int[] weights) {
        this.weights = weights;
    }

    public List<Term> getTerms() {
        return terms;
    }

    public void setTerms(List<Term> terms) {
        this.terms = terms;
    }
    
    public int getWeightsSum() {
        int sum=0;
        for (int weight : weights) {
            sum+=weight;
        }
        return sum;
    }

    public int getUnsatisfiableTermsCount(boolean[] array) {
        int counter=0;
        for (Term term : terms) {
            if(!term.isSatisfiable(array)) counter++;
        }
        return counter;
    }

    public int getSatisfiableTermsCount(boolean[] array) {
        int counter=0;
        for (Term term : terms) {
            if(term.isSatisfiable(array)) counter++;
        }
        return counter;
    }

    public int getBestWeight() {
        return bestWeight;
    }

    public void setBestWeight(int bestWeight) {
        this.bestWeight = bestWeight;
    }
}
